﻿namespace ysh.core
{
	using Autodesk.Revit.DB;
	using Autodesk.Revit.UI.Selection;

	/// <summary>
	/// Selection filter based on the user provided category name.
	/// </summary>
	public class SelectionFilterByCategory : ISelectionFilter
	{
		#region private methods

		//Private variable that holds category name.
		private string mCategory = "";

		#endregion


		#region constructor

		/// <summary>
		/// 
		/// </summary>
		/// <param name="category"></param>
		public SelectionFilterByCategory(string category)
		{
			mCategory = category;
		}

		#endregion

		#region public methods

		/// <summary>
		/// Allow the element selection if provided category is equal to selected one.
		/// </summary>
		/// <param name="elem"></param>
		/// <returns></returns>
		public bool AllowElement(Element elem)
		{
			//Check if category matches.
			if (elem.Category.Name == mCategory)
				return true;
			return false;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="reference"></param>
		/// <param name="position"></param>
		/// <returns></returns>
		public bool AllowReference(Reference reference, XYZ position)
		{
			return false;
		}

		#endregion




	}
}
